import React from 'react'
import {Route,Redirect,Switch} from 'react-router-dom'
// 页面
import NotFound from '../pages/404/nofound';
import Rec from '../pages/rec/rec';
import Rdetail from '../pages/rdetail/rdetail';
import Enc from '../pages/enc/enc';
import Edetail from '../pages/edetail/edetail';
import Topic from '../pages/topic/topic';
import Goods from '../pages/goods/goods';
import Login from '../pages/login/login';
import Reg from '../pages/reg/reg';
import User from '../pages/user/user';
// 组件
import Header from '../components/header/header';
import Footer from '../components/footer/footer';


function Default(){
    return (
        // 必须要一个元素来包含Switch,不能直接添加在根元素下面
        <div>
            <Header />
            {/* 排他性匹配 */}
            <Switch>
                {/* 商品页 exact严格匹配*/}
                <Route path='/rec' exact component={Rec} />
                {/* 商品详情页 */}
                <Route path='/rec/:_id' component={Rdetail} />
                {/* 百科页 */}
                <Route path='/enc' exact component={Enc} />
                {/* 百科详情页 */}
                <Route path='/enc/:_id' component={Edetail} />
                {/* 话题页 */}
                <Route path='/topic' component={Topic} />
                {/* 购物车 */}
                <Route path='/goods' component={Goods} />
                {/* 登陆页 */}
                <Route path='/login' component={Login} />
                {/* 注册页 */}
                <Route path='/reg' component={Reg} />
                {/* 个人页 */}
                <Route path='/user' component={User} />
                

                {/* 重定向 exact为true严格匹配*/}
                <Redirect exact from="/" to="/rec"/>
                {/* Route后面什么都不写默认全匹配,找不到就跳转到404 */}
                <Route component={NotFound} />
            </Switch>

            <Footer />
        </div>
    )

} 
export default Default;